package vg.services.graph_view_manager.realization.graph_comparison.algorithm;

import java.util.ArrayList;
import java.util.List;

// TODO
public class MCSVertexGroup {
	private List<MCSVertex> edges;
	private int currIndex = 0;
	
	public MCSVertexGroup() {
		this.edges = new ArrayList<MCSVertex>();
	}
	
	public void push(MCSVertex e) {
		edges.add(e);
	}
	
	public MCSVertex next() {
		currIndex++;
		return curr();
	}
	
	public MCSVertex curr() {
		if (currIndex >= edges.size())
			return null;
		else
			return edges.get(currIndex);
	}
	
	public boolean hasNext() {
		if (currIndex >= edges.size() - 1)
			return false;
		else
			return true;		
	}
	
	public void resetIndex() {
		currIndex = 0;
	}
	
	public int size() {
		return edges.size();
	}
	
	public boolean contains(MCSVertex e) {
		for (MCSVertex buf : edges) {
			if ((buf != null && e != null && buf.getSrc() == e.getSrc() && buf.getDst() == e.getDst()) || (buf == null && e == null)) {
				return true;
			}
		}
		return false;
	}
	
	@Override
	public String toString() {
		StringBuilder str = new StringBuilder();
		str.append("[");
		for (MCSVertex buf : edges) {
			if (buf == null) {
				str.append("null ");
			} else {
				str.append(buf.toString());
				str.append(" ");
			}
		}
		str.append("]");
		return str.toString();
	}
}
